package com.vhall.component.controller.dictionary;

import com.vhall.component.entity.dictionary.OptionVO;
import com.vhall.component.entity.dictionary.enums.SelectTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 获取枚举及字典信息
 *
 * @author shimingming
 * @since 2023/4/13 19:40
 */
@RestController
@RequestMapping("/v4/dictionary")
@Slf4j
public class DictionaryController {


    /**
     * 根据编码获取枚举信息
     * <p>
     * "placement_location", "投放位置"
     * <p>
     * "ad_type", "投放类型"
     */
    @GetMapping("/queryMultiOption")
    public Map<String, List<OptionVO>> queryMultiOption(@RequestParam("params") List<String> params) {
        Map<String, List<OptionVO>> resultMap = new HashMap<>();
        for (String param : params) {
            resultMap.put(param, doGetEnumOption(param));
        }
        return resultMap;
    }

    private List<OptionVO> doGetEnumOption(String code) {
        return SelectTypeEnum.getByCode(code);
    }

}
